package com.hwxt.ghs.vo;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.util.DigestUtils;
import org.thymeleaf.util.StringUtils;

import com.hwxt.ghs.utils.FileSizeUtils;

public class Project {
    // 项目名称
    private String name;
    // 本地路径
    private String path;
    // 分支个数
    private int branchs;
    // 提交个数
    private int commits;

    // 索引大小
    private long indexsize;
    // 索引路径
    private String indexpath;
    // 索引时间
    private long indextime;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPath() {
        return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
    public int getBranchs() {
        return branchs;
    }
    public void setBranchs(int branchs) {
        this.branchs = branchs;
    }
    public int getCommits() {
        return commits;
    }
    public void setCommits(int commits) {
        this.commits = commits;
    }
    public long getIndexsize() {
        return indexsize;
    }
    public void setIndexsize(long indexsize) {
        this.indexsize = indexsize;
    }
    public long getIndextime() {
        return indextime;
    }
    public void setIndextime(long indextime) {
        this.indextime = indextime;
    }

    public String getIndexpath() {
        if(StringUtils.isEmpty(indexpath) && !StringUtils.isEmpty(name) && !StringUtils.isEmpty(path)){
            this.indexpath = DigestUtils.md5DigestAsHex((name + "_" + path).getBytes());
        }
        return indexpath;
    }
    public void setIndexpath(String indexpath) {
        this.indexpath = indexpath;
    }

    public String getIndexTimeStr() {
        if(this.indextime > 0 ){
            Date date = new Date(this.getIndextime());
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        } else {
            return "";
        }
    }
    public String getIndexSizeStr( ) {
        return FileSizeUtils.sizeFormat(this.indexsize);
    }
    

}
